3.2.13 \(\int \sin ^2(a+\frac {b}{x}) \, dx\) [113]

Optimal. Leaf size=41 \[ -b \text {Ci}\left (\frac {2 b}{x}\right ) \sin (2 a)+x \sin ^2\left (a+\frac {b}{x}\right )-b \cos (2 a) \text {Si}\left (\frac {2 b}{x}\right ) \]

[Out]

-b*cos(2*a)*Si(2*b/x)-b*Ci(2*b/x)*sin(2*a)+x*sin(a+b/x)^2

________________________________________________________________________________________

Rubi [A]
time = 0.06, antiderivative size = 41, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 6, integrand size = 10, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.600, Rules used = {3442, 3394, 12, 3384, 3380, 3383} \begin {gather*} -b \sin (2 a) \text {CosIntegral}\left (\frac {2 b}{x}\right )-b \cos (2 a) \text {Si}\left (\frac {2 b}{x}\right )+x \sin ^2\left (a+\frac {b}{x}\right ) \end {gather*}

Antiderivative was successfully verified.

[In]

Int[Sin[a + b/x]^2,x]

[Out]

-(b*CosIntegral[(2*b)/x]*Sin[2*a]) + x*Sin[a + b/x]^2 - b*Cos[2*a]*SinIntegral[(2*b)/x]

Rule 12

Int[(a_)*(u_), x_Symbol] :> Dist[a, Int[u, x], x] /; FreeQ[a, x] &&  !MatchQ[u, (b_)*(v_) /; FreeQ[b, x]]

Rule 3380

Int[sin[(e_.) + (f_.)*(x_)]/((c_.) + (d_.)*(x_)), x_Symbol] :> Simp[SinIntegral[e + f*x]/d, x] /; FreeQ[{c, d,
 e, f}, x] && EqQ[d*e - c*f, 0]

Rule 3383

Int[sin[(e_.) + (f_.)*(x_)]/((c_.) + (d_.)*(x_)), x_Symbol] :> Simp[CosIntegral[e - Pi/2 + f*x]/d, x] /; FreeQ
[{c, d, e, f}, x] && EqQ[d*(e - Pi/2) - c*f, 0]

Rule 3384

Int[sin[(e_.) + (f_.)*(x_)]/((c_.) + (d_.)*(x_)), x_Symbol] :> Dist[Cos[(d*e - c*f)/d], Int[Sin[c*(f/d) + f*x]
/(c + d*x), x], x] + Dist[Sin[(d*e - c*f)/d], Int[Cos[c*(f/d) + f*x]/(c + d*x), x], x] /; FreeQ[{c, d, e, f},
x] && NeQ[d*e - c*f, 0]

Rule 3394

Int[((c_.) + (d_.)*(x_))^(m_)*sin[(e_.) + (f_.)*(x_)]^(n_), x_Symbol] :> Simp[(c + d*x)^(m + 1)*(Sin[e + f*x]^
n/(d*(m + 1))), x] - Dist[f*(n/(d*(m + 1))), Int[ExpandTrigReduce[(c + d*x)^(m + 1), Cos[e + f*x]*Sin[e + f*x]
^(n - 1), x], x], x] /; FreeQ[{c, d, e, f, m}, x] && IGtQ[n, 1] && GeQ[m, -2] && LtQ[m, -1]

Rule 3442

Int[((a_.) + (b_.)*Sin[(c_.) + (d_.)*((e_.) + (f_.)*(x_))^(n_)])^(p_.), x_Symbol] :> Dist[1/(n*f), Subst[Int[x
^(1/n - 1)*(a + b*Sin[c + d*x])^p, x], x, (e + f*x)^n], x] /; FreeQ[{a, b, c, d, e, f}, x] && IGtQ[p, 0] && In
tegerQ[1/n]

Rubi steps

\begin {align*} \int \sin ^2\left (a+\frac {b}{x}\right ) \, dx &=-\text {Subst}\left (\int \frac {\sin ^2(a+b x)}{x^2} \, dx,x,\frac {1}{x}\right )\\ &=x \sin ^2\left (a+\frac {b}{x}\right )-(2 b) \text {Subst}\left (\int \frac {\sin (2 a+2 b x)}{2 x} \, dx,x,\frac {1}{x}\right )\\ &=x \sin ^2\left (a+\frac {b}{x}\right )-b \text {Subst}\left (\int \frac {\sin (2 a+2 b x)}{x} \, dx,x,\frac {1}{x}\right )\\ &=x \sin ^2\left (a+\frac {b}{x}\right )-(b \cos (2 a)) \text {Subst}\left (\int \frac {\sin (2 b x)}{x} \, dx,x,\frac {1}{x}\right )-(b \sin (2 a)) \text {Subst}\left (\int \frac {\cos (2 b x)}{x} \, dx,x,\frac {1}{x}\right )\\ &=-b \text {Ci}\left (\frac {2 b}{x}\right ) \sin (2 a)+x \sin ^2\left (a+\frac {b}{x}\right )-b \cos (2 a) \text {Si}\left (\frac {2 b}{x}\right )\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]
time = 0.06, size = 41, normalized size = 1.00 \begin {gather*} -b \text {Ci}\left (\frac {2 b}{x}\right ) \sin (2 a)+x \sin ^2\left (a+\frac {b}{x}\right )-b \cos (2 a) \text {Si}\left (\frac {2 b}{x}\right ) \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[Sin[a + b/x]^2,x]

[Out]

-(b*CosIntegral[(2*b)/x]*Sin[2*a]) + x*Sin[a + b/x]^2 - b*Cos[2*a]*SinIntegral[(2*b)/x]

________________________________________________________________________________________

Maple [A]
time = 0.06, size = 52, normalized size = 1.27

method result size
derivativedivides \(-b \left (-\frac {x}{2 b}+\frac {\cos \left (2 a +\frac {2 b}{x}\right ) x}{2 b}+\sinIntegral \left (\frac {2 b}{x}\right ) \cos \left (2 a \right )+\cosineIntegral \left (\frac {2 b}{x}\right ) \sin \left (2 a \right )\right )\) \(52\)
default \(-b \left (-\frac {x}{2 b}+\frac {\cos \left (2 a +\frac {2 b}{x}\right ) x}{2 b}+\sinIntegral \left (\frac {2 b}{x}\right ) \cos \left (2 a \right )+\cosineIntegral \left (\frac {2 b}{x}\right ) \sin \left (2 a \right )\right )\) \(52\)
risch \(\frac {\pi \,\mathrm {csgn}\left (\frac {b}{x}\right ) {\mathrm e}^{-2 i a} b}{2}-\sinIntegral \left (\frac {2 b}{x}\right ) {\mathrm e}^{-2 i a} b +\frac {i \expIntegral \left (1, -\frac {2 i b}{x}\right ) {\mathrm e}^{-2 i a} b}{2}-\frac {i b \expIntegral \left (1, -\frac {2 i b}{x}\right ) {\mathrm e}^{2 i a}}{2}+\frac {x}{2}-\frac {x \cos \left (\frac {2 a x +2 b}{x}\right )}{2}\) \(85\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(sin(a+b/x)^2,x,method=_RETURNVERBOSE)

[Out]

-b*(-1/2*x/b+1/2*cos(2*a+2*b/x)/b*x+Si(2*b/x)*cos(2*a)+Ci(2*b/x)*sin(2*a))

________________________________________________________________________________________

Maxima [C] Result contains complex when optimal does not.
time = 0.37, size = 66, normalized size = 1.61 \begin {gather*} -\frac {1}{2} \, {\left ({\left (-i \, {\rm Ei}\left (\frac {2 i \, b}{x}\right ) + i \, {\rm Ei}\left (-\frac {2 i \, b}{x}\right )\right )} \cos \left (2 \, a\right ) + {\left ({\rm Ei}\left (\frac {2 i \, b}{x}\right ) + {\rm Ei}\left (-\frac {2 i \, b}{x}\right )\right )} \sin \left (2 \, a\right )\right )} b - \frac {1}{2} \, x \cos \left (\frac {2 \, {\left (a x + b\right )}}{x}\right ) + \frac {1}{2} \, x \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(a+b/x)^2,x, algorithm="maxima")

[Out]

-1/2*((-I*Ei(2*I*b/x) + I*Ei(-2*I*b/x))*cos(2*a) + (Ei(2*I*b/x) + Ei(-2*I*b/x))*sin(2*a))*b - 1/2*x*cos(2*(a*x
 + b)/x) + 1/2*x

________________________________________________________________________________________

Fricas [A]
time = 0.36, size = 56, normalized size = 1.37 \begin {gather*} -x \cos \left (\frac {a x + b}{x}\right )^{2} - b \cos \left (2 \, a\right ) \operatorname {Si}\left (\frac {2 \, b}{x}\right ) - \frac {1}{2} \, {\left (b \operatorname {Ci}\left (\frac {2 \, b}{x}\right ) + b \operatorname {Ci}\left (-\frac {2 \, b}{x}\right )\right )} \sin \left (2 \, a\right ) + x \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(a+b/x)^2,x, algorithm="fricas")

[Out]

-x*cos((a*x + b)/x)^2 - b*cos(2*a)*sin_integral(2*b/x) - 1/2*(b*cos_integral(2*b/x) + b*cos_integral(-2*b/x))*
sin(2*a) + x

________________________________________________________________________________________

Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \sin ^{2}{\left (a + \frac {b}{x} \right )}\, dx \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(a+b/x)**2,x)

[Out]

Integral(sin(a + b/x)**2, x)

________________________________________________________________________________________

Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 153 vs. \(2 (41) = 82\).
time = 5.27, size = 153, normalized size = 3.73 \begin {gather*} -\frac {2 \, a b^{2} \operatorname {Ci}\left (-2 \, a + \frac {2 \, {\left (a x + b\right )}}{x}\right ) \sin \left (2 \, a\right ) - 2 \, a b^{2} \cos \left (2 \, a\right ) \operatorname {Si}\left (2 \, a - \frac {2 \, {\left (a x + b\right )}}{x}\right ) - \frac {2 \, {\left (a x + b\right )} b^{2} \operatorname {Ci}\left (-2 \, a + \frac {2 \, {\left (a x + b\right )}}{x}\right ) \sin \left (2 \, a\right )}{x} + \frac {2 \, {\left (a x + b\right )} b^{2} \cos \left (2 \, a\right ) \operatorname {Si}\left (2 \, a - \frac {2 \, {\left (a x + b\right )}}{x}\right )}{x} - b^{2} \cos \left (\frac {2 \, {\left (a x + b\right )}}{x}\right ) + b^{2}}{2 \, {\left (a - \frac {a x + b}{x}\right )} b} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(a+b/x)^2,x, algorithm="giac")

[Out]

-1/2*(2*a*b^2*cos_integral(-2*a + 2*(a*x + b)/x)*sin(2*a) - 2*a*b^2*cos(2*a)*sin_integral(2*a - 2*(a*x + b)/x)
 - 2*(a*x + b)*b^2*cos_integral(-2*a + 2*(a*x + b)/x)*sin(2*a)/x + 2*(a*x + b)*b^2*cos(2*a)*sin_integral(2*a -
 2*(a*x + b)/x)/x - b^2*cos(2*(a*x + b)/x) + b^2)/((a - (a*x + b)/x)*b)

________________________________________________________________________________________

Mupad [F]
time = 0.00, size = -1, normalized size = -0.02 \begin {gather*} \int {\sin \left (a+\frac {b}{x}\right )}^2 \,d x \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(sin(a + b/x)^2,x)

[Out]

int(sin(a + b/x)^2, x)

________________________________________________________________________________________